import xlrd
from ChatbotWithRetrieval import ChatbotWithRetrieval

# 打开文件
data = xlrd.open_workbook(r'C:\Users\Yang.Shen9\PycharmProjects\goudan-llm\custom-streamlit\data\客服知识.xlsx')

vlanSheet1 = data.sheet_by_index(0)

vlanNrows = vlanSheet1.nrows

llm = ChatbotWithRetrieval("")
faiss = llm.store
for r in range(0, vlanNrows):
    question = vlanSheet1.cell(r, 0).value
    answer = vlanSheet1.cell(r, 1).value
    print(question)
    print(answer)
    template = f"""Product information or Q&A examples : {question} ;   {answer} """
    idsdf = faiss.write_templates(template)
    print("data=id=" + str(idsdf))
faiss.write_templates("312342342342423423")
template = """Product information or Q&A examples"""
faiss.write_templates(template)
results_with_scores = faiss.similarity_search_with_score('Product', dict(data='jhd'))
for doc in results_with_scores:
    print(f"Content: {doc.page_content}, Metadata: {doc.metadata}")
faiss.del_data(["892876083bc24f52a0c307a1ed0ecc37"])
for doc in faiss.all_data():
    print(f"Content: {doc}")